import React, {Component} from 'react';

class Tablebar extends Component {
    state = {}
    render() {
        return (
            <div>
                <ul>
                    {
                        this.props.list.map((item, index) =>
                            <li key={item.id} className={this.props.current === index ? 'activeaa' : ''} onClick={()=>{
                                this.clickCurrent(index)
                            }}>
                                {item.name}</li>
                        )
                    }
                </ul>
            </div>
        );
    }

    clickCurrent(index){
        console.log(index)
        this.setState({
            current:index
        })
        //通知一下父组件,修改父组件那个状态
        this.props.event(index)
    }
}

export default Tablebar;
